
#ifndef APPLICATIONS_LCD_INIT_H_
#define APPLICATIONS_LCD_INIT_H_


#define USE_HORIZONTAL 1


#if USE_HORIZONTAL==0||USE_HORIZONTAL==1
#define LCD_W 128
#define LCD_H 160

#else
#define LCD_W 160
#define LCD_H 128
#endif

#define u8  unsigned char
#define u16 unsigned int

#define LCM_SCLK        63      //PC6 -SCL-SCLK
#define LCM_MOSI        65      //PC8-SDA
#define LCM_RES         66      //PC9
#define LCM_DC          78      //PC10
#define LCM_CS          80      //PC12
#define LCM_BLK         82      //PD1

/*
sbit LCD_SCL=P1^0;//SCLK
sbit LCD_SDA=P1^1;//MOSI
sbit LCD_RES=P1^2;//RES
sbit LCD_DC =P1^3;//DC
sbit LCD_CS =P1^4; //CS
sbit LCD_BLK=P1^5; //BLK
*/

#define LCD_SCLK_Clr() rt_pin_write(LCM_SCLK, PIN_LOW)
#define LCD_SCLK_Set() rt_pin_write(LCM_SCLK, PIN_HIGH)

#define LCD_MOSI_Clr() rt_pin_write(LCM_MOSI, PIN_LOW)
#define LCD_MOSI_Set() rt_pin_write(LCM_MOSI, PIN_HIGH)

#define LCD_RES_Clr()   rt_pin_write(LCM_RES, PIN_LOW)
#define LCD_RES_Set()   rt_pin_write(LCM_RES, PIN_HIGH)

#define LCD_DC_Clr()    rt_pin_write(LCM_DC, PIN_LOW)
#define LCD_DC_Set()    rt_pin_write(LCM_DC, PIN_HIGH)

#define LCD_CS_Clr()    rt_pin_write(LCM_CS, PIN_LOW)
#define LCD_CS_Set()    rt_pin_write(LCM_CS, PIN_HIGH)

#define LCD_BLK_Clr()   rt_pin_write(LCM_BLK, PIN_LOW)
#define LCD_BLK_Set()   rt_pin_write(LCM_BLK, PIN_HIGH)



void delay_ms(unsigned int ms);
void LCD_GPIO_Init(void);
void LCD_Writ_Bus(u8 dat);
void LCD_WR_DATA8(u8 dat);
void LCD_WR_DATA(u16 dat);
void LCD_WR_REG(u8 dat);
void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2);
void LCD_Init(void);


#endif /* APPLICATIONS_LCD_INIT_H_ */
